package com.scrx.ymg.action;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.gson.Gson;
import com.scrx.ymg.entity.AgentHot;
import com.scrx.ymg.entity.AgentInfo;
import com.scrx.ymg.entity.DividedInto;
import com.scrx.ymg.entity.HeadEntrepot;
import com.scrx.ymg.entity.HeadMoney;
import com.scrx.ymg.entity.HeadWithdarw;
import com.scrx.ymg.entity.SuperMarketInfo;
import com.scrx.ymg.service.head.IHeadService;
import com.scrx.ymg.service.supermarket.ISuperMarketService;

@Controller
@RequestMapping("/headAction")
public class HeadAction {

	@Autowired
	private IHeadService heads;
	@Autowired
	private ISuperMarketService supers;
	
	/**
	 * 删除总部商品
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/deleteHeadProduct",produces = "text/json;charset=UTF-8")
	public String deleteHeadProduct(HeadEntrepot head){
		return heads.deleteHeadProduct(head);
	}
	
	/**
	 * 审核爆款商品
	 * @param hot
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/checkHotProduct",produces = "text/json;charset=UTF-8")
	public String checkHotProduct(AgentHot hot){
		return heads.checkHotProduct(hot);
	}
	/**
	 * 查询提现设置
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/selectHeadWithdarw",produces = "text/json;charset=UTF-8")
	public String selectHeadWithdarw(){
		HeadWithdarw head = heads.selectHeadWithdarw();
		Gson gson = new Gson();
		return gson.toJson(head);
	}
	/**
	 * 更新提现设置
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/updateHeadWithdarw",produces = "text/json;charset=UTF-8")
	public String updateHeadWithdarw(HeadWithdarw head){
		return heads.updateHeadWithdarw(head);
	}
	
	/**
	 * 代理商更新支付方式
	 * @param info
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/updateAgentInfo",produces = "text/json;charset=UTF-8")
	public String updateAgentInfo(AgentInfo info){
		return heads.updateAgentInfo(info);
	}
	
	/**
	 * 超市更新支付方式
	 * @param info
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/updateSuperMarketInfo",produces = "text/json;charset=UTF-8")
	public String updateSuperMarketInfo(SuperMarketInfo info){
		return heads.updateSuperMarketInfo(info);
	}
	
	/**
	 * 得到超市开店申请信息
	 * @param info
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/getSuperMarketInfo",produces = "text/json;charset=UTF-8")
	public String getSuperMarketInfo(SuperMarketInfo info){
		SuperMarketInfo oldinfo = heads.getSuperMarketInfo(info);
		Gson gson = new Gson();
		return gson.toJson(oldinfo);
	}
	
	/**
	 * 审核失败删除超市
	 * @param info
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/deleteSuperMarketInfo",produces = "text/json;charset=UTF-8")
	public String deleteSuperMarketInfo(SuperMarketInfo info){
		return supers.deleteSuperMarketInfo(info);
	}
	
	/**
	 * 审核超市通过
	 * @param info
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/checkSuperMarketInfo",produces = "text/json;charset=UTF-8")
	public String checkSuperMarketInfo(SuperMarketInfo info){
		return supers.checkSuperMarketInfo(info);
	}
	
	/**
	 * 查询申请冻结,申请恢复超市
	 * @param info
	 * @param pageNum
	 * @param pageCount
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/getSuperMarketInfoByStatus",produces = "text/json;charset=UTF-8")
	public String getSuperMarketInfoByStatus(SuperMarketInfo info,int pageNum,int pageCount){
		Map<Object,Object> map = supers.getSuperMarketInfoByStatus(info,pageNum,pageCount);
		Gson gson = new Gson();
		return gson.toJson(map);
	}
	
	/**
	 * 查询分成设置
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/selectDividedInto",produces = "text/json;charset=UTF-8")
	public String selectDividedInto(){
		DividedInto into=heads.selectDividedInto();
		Gson gson = new Gson();
		return gson.toJson(into);
	}
	
	/**
	 * 更新分成设置
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/updateDividedInto",produces = "text/json;charset=UTF-8")
	public String updateDividedInto(DividedInto into){
		return heads.updateDividedInto(into);
	}
	
	/**
	 * 总部账户金额
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/getHeadMoney",produces = "text/json;charset=UTF-8")
	public String getHeadMoney(){
		HeadMoney headMoney=heads.getHeadMoney();
		Gson gson = new Gson();
		return gson.toJson(headMoney);
	}
	

}
